<template>
  <div>
    <nav-bar>
      <div slot="left" @click="back"><i class="el-icon-arrow-left"></i></div>
      <div slot="center" class="title">
        <div
          class="title-item"
          v-for="(item,index) in title"
          :key="index"
          :class="{active:index===currentIndex}"
          @click="itemClick(index)">
          {{item}}
        </div>
      </div>
    </nav-bar>
  </div>
</template>

<script>
  import NavBar from 'components/common/navbar/NavBar'

  export default {
    name: "DatailNavBar",
    components: {
      NavBar
    },
    data() {
      return {
        title: ['商品', '参数', '评论', '推荐'],
        currentIndex: 0
      }
    },
    methods: {
      itemClick(index) {
        this.currentIndex = index
      },
      back() {
        this.$router.go(-1)
      }
    }
  }

</script>
<style scoped>
  .title {
    display: flex;
  }

  .title-item {
    flex: 1;
    font-size: 14px;
  }

  .active {
    color: red;
  }
</style>
